package com.ruoyi.factorydata.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.factorydata.mapper.EquipmentTypeMapper;
import com.ruoyi.factorydata.domain.EquipmentType;
import com.ruoyi.factorydata.service.IEquipmentTypeService;

/**
 * 设备类型Service业务层处理
 *
 * @author ruoyi
 * @date 2025-07-04
 */
@Service
public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, EquipmentType> implements IEquipmentTypeService {
    @Autowired
    private EquipmentTypeMapper equipmentTypeMapper;

    /**
     * 查询设备类型
     *
     * @param id 设备类型主键
     * @return 设备类型
     */
    @Override
    public EquipmentType selectEquipmentTypeById(Long id) {
        return equipmentTypeMapper.selectEquipmentTypeById(id);
    }

    /**
     * 查询设备类型列表
     *
     * @param equipmentType 设备类型
     * @return 设备类型
     */
    @Override
    public List<EquipmentType> selectEquipmentTypeList(EquipmentType equipmentType) {
        return equipmentTypeMapper.selectEquipmentTypeList(equipmentType);
    }

    /**
     * 新增设备类型
     *
     * @param equipmentType 设备类型
     * @return 结果
     */
    @Override
    public int insertEquipmentType(EquipmentType equipmentType) {
                equipmentType.setCreateTime(DateUtils.getNowDate());
            return equipmentTypeMapper.insertEquipmentType(equipmentType);
    }

    /**
     * 修改设备类型
     *
     * @param equipmentType 设备类型
     * @return 结果
     */
    @Override
    public int updateEquipmentType(EquipmentType equipmentType) {
                equipmentType.setUpdateTime(DateUtils.getNowDate());
        return equipmentTypeMapper.updateEquipmentType(equipmentType);
    }

    /**
     * 批量删除设备类型
     *
     * @param ids 需要删除的设备类型主键
     * @return 结果
     */
    @Override
    public int deleteEquipmentTypeByIds(Long[] ids) {
        int i = equipmentTypeMapper.deleteBatchIds(Arrays.stream(ids).collect(Collectors.toList()));
        return i;
    }

    /**
     * 删除设备类型信息
     *
     * @param id 设备类型主键
     * @return 结果
     */
    @Override
    public int deleteEquipmentTypeById(Long id) {
        return equipmentTypeMapper.deleteEquipmentTypeById(id);
    }
}